<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Bank extends Model
{
    const CREATED_AT = 'insert_time';
    const UPDATED_AT = 'update_time';
    /**
     * 与模型关联的数据表。
     *
     * @var string
     */
    protected $table = 'lexiang_bankcard';

    protected $primaryKey = 'bank_id';

    public $timestamps = false;

    /**
     * 可以被批量赋值的属性。
     *
     * @var array
     */
    protected $fillable = [
    	'users_id','bank_name','bank_number',
    	'openbank','bank_tel','company_id',
    	'insert_time','update_time'
    ];

    public function createBankCard($createData,$userid)
    {
    	$nowtime = time();
    	foreach ($createData as $key => $value) {
    		$this->$key = $value;
    	}
    	$this->insert_time = $nowtime;
    	$this->users_id = $userid;

    	if($this->save()){
    		return [
    			'success'=>true,
    			'code'=>'000',
    			'message'=>'修改成功',
    			'data'=>[
    				'bank_id'=>$this->bank_id
    			]
    		];
    	}else{
    		return [
    			'success'=>false,
    			'code'=>'006',
    			'message'=>'修改失败，请稍后再试',
    		];
    	}
    }
}
